package com.homework.controller;

import com.homework.dto.Result;
import com.homework.service.AnalyticsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/analytics")
@RequiredArgsConstructor
public class AnalyticsController {

    private final AnalyticsService analyticsService;

    /**
     * 获取开始时间趋势数据
     */
    @GetMapping("/start-time-trend")
    public Result<List<Map<String, Object>>> getStartTimeTrend(@RequestParam Long studentId) {
        return analyticsService.getStartTimeTrend(studentId);
    }

    /**
     * 获取完成时间趋势数据
     */
    @GetMapping("/completion-time-trend")
    public Result<List<Map<String, Object>>> getCompletionTimeTrend(@RequestParam Long studentId) {
        return analyticsService.getCompletionTimeTrend(studentId);
    }

    /**
     * 获取月度日历数据
     */
    @GetMapping("/calendar/{year}/{month}")
    public Result<Map<String, Object>> getCalendarData(
            @PathVariable Integer year,
            @PathVariable Integer month,
            @RequestParam Long studentId) {
        return analyticsService.getCalendarData(studentId, year, month);
    }

    /**
     * 获取作业完成记录
     */
    @GetMapping("/homework-records")
    public Result<List<Map<String, Object>>> getHomeworkRecords(
            @RequestParam Long studentId,
            @RequestParam Integer year,
            @RequestParam Integer month) {
        return analyticsService.getHomeworkRecords(studentId, year, month);
    }
}